import java.util.*;

public class demo03 {
    //图像模糊
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[][] arr=new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j]=sc.nextInt();
            }
        }
        int[][] arr1=new int[n][m];
        func(arr,arr1);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                System.out.print(arr1[i][j]+" ");
            }
            System.out.println();
        }
    }
    public static void func(int[][] arr,int[][] arr1){
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                int sum=0;
                int count=1;
                sum+=arr[i][j];
                if(i-1>=0&&j-1>=0){
                    sum+=arr[i-1][j-1];
                    count++;
                }
                if(i-1>=0){
                    sum+=arr[i-1][j];
                    count++;
                }
                if(i-1>=0&&j+1<arr[i].length){
                    sum+=arr[i-1][j+1];
                    count++;
                }
                if(j-1>=0){
                    sum+=arr[i][j-1];
                    count++;
                }
                if(j+1<arr[i].length){
                    sum+=arr[i][j+1];
                    count++;
                }
                if(i+1<arr.length&&j-1>=0){
                    sum+=arr[i+1][j-1];
                    count++;
                }
                if(i+1<arr.length){
                    sum+=arr[i+1][j];
                    count++;
                }
                if(i+1<arr.length&&j+1<arr[i].length){
                    sum+=arr[i+1][j+1];
                    count++;
                }
                arr1[i][j]=sum/count;
            }
        }
    }
}
